<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/views/global/taglibs.jsp" %>
<!DOCTYPE>
<html>
  <head>
    <base href="<%=basePath %>">
    <%@include file="/views/global/include.jsp" %>
	<link href="static/css/global/generic.css" rel="stylesheet" type="text/css">
	<link href="static/css/page/loginRegister.css" rel="stylesheet" type="text/css">
	<title>Sign In</title>
	
  </head>
  
  <body>
  	<div id="loginPage" class="center">
		<div class="loginHeader">
			<div class="headerArrow center"></div>
		</div>
		<div class="font textCenter loginTitle">W&nbsp;&nbsp;E&nbsp;&nbsp;L&nbsp;&nbsp;C&nbsp;&nbsp;O&nbsp;&nbsp;M&nbsp;&nbsp;E</div>
		<div class="font textCenter loginSubTitle">开启探索之旅</div>
		<form id="loginForm" class="form-horizontal validate" method="post" errorPlacement="errorPlacement" autocomplete="off">
			<input type="hidden" name="originURL" value="${originURL }"/>
			<ul>
				<li>
					<input id="userName" name="userName" type="text" class="en_M radius"
					 placeholder="USER NAME 用户名" required="account required" validateChar="true">
					<!-- <span class="error">&nbsp;</span> -->
				</li>
				<li>
					<input id="userPassword" name="userPassword" type="password" class="en_M radius"
						 placeholder="PASSWORD 密码" required="password required" onkeypress="javascript:autoSubmit(event);">
					<!-- <span class="error">&nbsp;</span> -->
				</li>
			</ul>
			<button id="loginButton" type="button" class="radius en_M" onclick="login(this);">SIGN IN NOW 立即登陆</button>
			<div class="clearfix" style="background:#fff;height: 100px;">
				<div id="msg" style="height:40px;margin-top: 15px;"></div>
				<a href="views/account/ForgetPassword.jsp" style="display: inline-block;"><div id="forget" class="font left en_SS" style="margin:-40px 0 0 39px;padding-bottom:15px;">FORGET PASSWARD ?<br>忘记密码？</div></a>
				<a href="register"  style="display: inline-block;"><div id="registerEntry" class="font right en_SS" style="margin:-40px 0 0 111px;padding-bottom:15px;">REGISTER HERE !<br>立即注册！</div></a>
			</div>
		</form>
	</div>
	<%@include file="/views/global/AdminScripts.jsp" %>
  </body>
<script type="text/javascript">
document.errorPlacement = function(error, element){
	error.appendTo( element.parent().find(".error") );
}
$(document).ready(function(){
	$("#userName").focus();
});

function login(){
	var validator = $("#loginForm").validate({meta:"validate"});
	if(validator.form()){
        $("#loginForm").goAjax({
    		semantic: false,
    		url: 'login',
    		data:{},
    		success: function(jsonData) {
    			if(true == jsonData.success){
    				if("true" == '${usePanel }'){
    					art.dialog.data("logined", true);
    					art.dialog.data("refresh.now", "true");
        				art.dialog.close();
    				} else {
    					window.location.href = jsonData.message;
    				}
    			} else {
    				$("#msg").alert({type:'alert-danger', text: jsonData.message});
    			}
    		}
    	});
	} else {
		$.message("Please input your username and password manually!");
	}
}

function autoSubmit(event){
	if(event.keyCode==13){
		login();
	}
}
</script>
</html>
